package algorithm.beforestart.primary.array;

import java.util.HashSet;

public class removeDuplicates {

    public static int removeDuplicates(int[] nums) {
        HashSet set =new HashSet();
        int len=nums.length;
        for(int i=0;i<len;i++){
            if(set.contains(nums[i])){
                len--;
                for(int k=i;k<nums.length-1;k++){
                    nums[k]=nums[k+1];
                }
                i--;

            }else{
                set.add(nums[i]);
            }

        }
        for(int i=0;i<len;i++){
            System.out.println(nums[i]);
        }

        return len;
    }



    public static void main(String[] args) {
        int[] nums={0,0,1,1,1,2,2,3,3,4};
       removeDuplicates(nums);
    }
}
